<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>事件绑定</title>
    <script src="../vue.global.js"></script>
</head>
<body>
<div id="app"></div>
<script>
    const app = Vue.createApp({
        data() {
            return {
                counter: 0
            }
        },
        methods: {
            handleBtnClick(num,event){
                console.log(event);
                console.log(event.target)
                this.counter += num
            },
            handleBtnOne(){
                alert(1)
            },
            handleBtnTwo(){
                alert(2)
            }
        },
        /**
         * 事件修饰符：
         *      stop阻止事件冒泡
         *      prevent: 阻止默认行为
         *      capture 捕获从外到内执行
         *      self 判断是否是自己的 dom行为
         *      once 只执行一次
         *      @scroll.passive 提升滚动性能
         * 按键修饰符：
         *      @keydown="" 按下键盘
         *      @keydown.enter="" 按下enter键的时候触发
         *      tab,delete,enter,esc,up,down,left,right
         *  鼠标修饰符：
         *      @click.left=""   鼠标左键、右键
         *      @click.middle="" 鼠标中间的滚轮
         *   精确修饰符
         *      @click.ctrl.exact="" 只按住ctrl点击才有效
         */
        template: `
          {{counter}}
          <button @click="handleBtnClick(2,$event)">按钮1</button>
          <button @click="handleBtnOne(),handleBtnTwo()">按钮2</button>

          <div @click.capture="handleBtnOne">
            <button @click="handleBtnTwo">BTN</button>
          </div>
        `
    });
    const vm = app.mount("#app");
</script>
</body>
</html>